package demo1;

class Shape {
    public void draw() {
        System.out.println("画图形！");
    }
}
class Rect extends Shape {
    @Override
    public void draw() {
        System.out.println("矩形");
    }
}
class Circle extends Shape {
    @Override
    public void draw() {
        System.out.println("圆");
    }
}
class Flower extends Shape {
    @Override
    public void draw() {
        System.out.println("❀");
    }
}
class Triangle extends Shape {
    @Override
    public void draw() {
        System.out.println("🔺");
    }
}
public class Test8_2 {
//    public static void drawMap(Shape shape) {
//        shape.draw();
//    }
    public static void drawMaps() {
        Circle circle = new Circle();
        Rect rect = new Rect();
        Flower flower = new Flower();
        Triangle triangle = new Triangle();

        Shape[] shapes = {circle,rect,circle,rect,flower,triangle};//发生了向下转型
        for (Shape shape:shapes) {
            shape.draw();
        }
    }

    public static void main(String[] args) {
        drawMaps();
    }
//    public static void main1(String[] args) {
//        Circle circle = new Circle();
//        Rect rect = new Rect();
//        Flower flower = new Flower();
//
//        drawMap(circle);
//        drawMap(rect);
//        drawMap(flower);
//    }
}
